package com.service;

import java.util.List;
import java.util.Vector;
import java.util.concurrent.CountDownLatch;

import com.model.ProxyIp;

public class GetPageThread extends Thread{
	Vector<ProxyIp> iplist;
	String url;
	CountDownLatch latch;
	long inittime;
	public GetPageThread(Vector<ProxyIp> iplist,String url,CountDownLatch latch,long inittime){
		this.iplist = iplist;
		this.url = url;
		this.latch = latch;
		this.inittime = inittime;
	}
	
	@Override
	public void run() {
		List<ProxyIp> list = ProxyIpService.parseProxyIp(url);
		String []strings = url.split("/");
		String pages = strings[strings.length-1];
		long time = System.currentTimeMillis() - inittime;
		if(list != null && list.size() > 0){
			iplist.addAll(list);
			System.out.println("pages:"+pages+"  size:"+list.size()+", 耗时："+time+"ms");
		}else{
			System.out.println("pages:"+pages+"  size:0"+", 耗时："+time+"ms");
		}
		latch.countDown();
	}
}
